package edu.msg.hrappy.backend.model;

import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;

@Entity
@Table(name = "Comment")
public class Comment extends BaseEntity {

    /**
     *
     */
    private static final long serialVersionUID = 1L;
    private String text;
    private Date date;
    private User commenter;

    public Comment() {
    }

    
    public Comment(String text, Date date, User commenter) {
        this.text = text;
        this.date = date;
        this.commenter = commenter;
    }

    public Comment(Long id, String text, Date date, User commenter) {
        super(id);
        this.text = text;
        this.date = date;
        this.commenter = commenter;
    }

    @Column(name = "text")
    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    @Temporal(javax.persistence.TemporalType.TIMESTAMP)
    @Column(name = "date")
    public Date getDate() {
        return (date == null) ? null : (Date) date.clone();
    }

    public void setDate(Date date) {
        this.date = date;
    }

    @OneToOne
    @JoinColumn (name="USER_ID")
    public User getCommenter() {
        return commenter;
    }

    public void setCommenter(User commenter) {
        this.commenter = commenter;
    }

}
